package com.hncgy.xzf.jdapi.controller.index;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hncgy.xzf.jdapi.domain.index.QuickMenu;
import com.hncgy.xzf.jdapi.service.index.IQuickMenuService;
import com.hncgy.xzf.jdapi.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 快捷菜单表 前端控制器
 * </p>
 *
 * @author 不会代码的蜡笔
 * @since 2025-10-31
 */
@RestController
@RequestMapping("/index/quickMenu")
public class QuickMenuController {

    @Autowired
    private IQuickMenuService quickMenuService;

    @RequestMapping("/list")
    public Result<List<QuickMenu>> list(QuickMenu quickMenu) {
        try {
            QueryWrapper<QuickMenu> quickMenuQueryWrapper = new QueryWrapper<>();
            quickMenuQueryWrapper.lambda()
                    .like(StringUtils.hasText(quickMenu.getName()),
                            QuickMenu::getName,
                            quickMenu.getName());
            List<QuickMenu> data = quickMenuService.list(quickMenuQueryWrapper);
            return Result.success(data);
        } catch (Exception e) {
            return Result.error("查询失败: " + e.getMessage());
        }
    }

}
